# frozen_string_literal: true

class CreateDecisionTableHeaders < ActiveRecord::Migration[6.0]
  def change
    create_table :decision_table_headers do |t|
      t.integer :decision_table_id,   null: false,  limit: 8
      t.integer :schema_variable_id,  null: false,  limit: 8
      t.string  :name,                null: false,  limit: 255
      t.integer :type_method_id,      null: false,  limit: 8
      t.integer :ordinal,             null: false,  limit: 4
      t.timestamps                    null: false
    end

    add_index :decision_table_headers, %i[ordinal decision_table_id], unique: true
    add_foreign_key :decision_table_headers, :rule_entities, column: :decision_table_id
    add_foreign_key :decision_table_headers, :schema_variables
    add_foreign_key :decision_table_headers, :type_methods
  end
end
